﻿using System;
using MugenMvvmToolkit.Models;

namespace MugenMvvmToolkit.Interfaces
{
#if !TASKSUPPORT
    /// <summary>
    ///     Represents the operation result.
    /// </summary>
    public interface IOperationResult : IAsyncResult
    {
        /// <summary>
        ///     Gets whether the operation completed due to an unhandled exception.
        /// </summary>
        /// <returns>
        ///     true if the task has thrown an unhandled exception; otherwise false.
        /// </returns>
        bool IsFaulted { get; }

        /// <summary>
        ///     Gets the exception that caused the operation to end prematurely. If the operation completed successfully or has not
        ///     yet thrown any exceptions, this will return null.
        /// </summary>
        Exception Exception { get; }

        /// <summary>
        ///     Gets the <see cref="OperationStatus" /> of this operation.
        /// </summary>
        OperationStatus Status { get; }

        /// <summary>
        ///     Begins wait for the operation to complete execution.
        /// </summary>
        /// <param name="callback">The specified callback.</param>
        void BeginWait(Action<IOperationResult> callback);
    }

    /// <summary>
    ///     Represents the operation result.
    /// </summary>
    public interface IOperationResult<T> : IOperationResult
    {
        /// <summary>
        ///     Gets the result value of this operation.
        /// </summary>
        T Result { get; }

        /// <summary>
        ///     Begins wait for the operation to complete execution.
        /// </summary>
        /// <param name="callback">The specified callback.</param>
        void BeginWait(Action<IOperationResult<T>> callback);
    }
#endif
}